package cbbx_sm.probabilistic_model;

import java.util.HashMap;

import cbbx_sm.utils.Timestamp;

/**
 * Represent the state of the system at a given instant.
 * In our case, it represents if clusters contain some events or not.
 * 
 * @author Alessio Della Motta - University of California, Irvine
 *
 */
public class SystemState {
	private Timestamp timestamp;
	private HashMap<Cluster, ClusterAttributes> clusterStates;
	
	public SystemState(Timestamp timestamp, HashMap<Cluster, ClusterAttributes> clusterStates){
		this.setTimestamp(timestamp);
		
		if (clusterStates != null)
			this.clusterStates = new HashMap<Cluster, ClusterAttributes>(clusterStates);
		else this.clusterStates = new HashMap<Cluster, ClusterAttributes>();
	}

	/**
	 * If the cluster is not present in the list, I suppose there
	 * are no events.
	 * 
	 * @param c
	 * @return
	 */
	public ClusterAttributes getAttributes(Cluster c){
		ClusterAttributes attributes = clusterStates.get(c);
		
		if (attributes == null) 
			return null;
		else return attributes;
	}
	
	public HashMap<Cluster, ClusterAttributes> getClusterStates() {
		return clusterStates;
	}
	
	public void setTimestamp(Timestamp timestamp) {
		this.timestamp = timestamp;
	}

	public Timestamp getTimestamp() {
		return timestamp;
	}

	@Override
	public String toString() {
		return "SystemState [clusterStates=" + clusterStates + ", timestamp="
				+ timestamp + "]";
	}
	
}
